package com.example.activity;

import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import com.example.activity.adapter.Myadapter;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private ViewPager pager;
    private Myadapter adapter;
    private List<View> allViews;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        pager = (ViewPager) findViewById(R.id.pager);
        allViews = new ArrayList<>();
        View view1 = LayoutInflater.from(this).inflate(R.layout.page_one_list,null);
       View view2 =  LayoutInflater.from(this).inflate(R.layout.page_two_list,null);
       View view3 =  LayoutInflater.from(this).inflate(R.layout.page_three_list,null);
        allViews.add(view1);
        allViews.add(view2);
        allViews.add(view3);
        adapter = new Myadapter(allViews);
        pager.setOffscreenPageLimit(3);
        pager.setAdapter(adapter);
    }
}
